package com.yuzai.reading.controllers;

import com.yuzai.reading.commons.result.Result;
import com.yuzai.reading.entitys.NoticeEntity;
import com.yuzai.reading.services.NoticesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/api/v1/notices")
public class NoticesController {

    @Autowired
    private NoticesService noticesService;

    @GetMapping("/{type}")
    public Result notice(@PathVariable int type) {
        List<NoticeEntity> notices = noticesService.queryNotices(type);
        Result<List<NoticeEntity>> success = Result.success(notices);
        return success;
    }
}
